package adminuser

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"gitee.com/liuxuezhan/ar-platform/rpc-client/userServiceClient/userrpc"
	"github.com/zeromicro/go-zero/core/logc"
	"github.com/zeromicro/go-zero/core/logx"
)

type AdminUserUpdateStatusLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 启用/禁用管理员用户
func NewAdminUserUpdateStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminUserUpdateStatusLogic {
	return &AdminUserUpdateStatusLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AdminUserUpdateStatusLogic) AdminUserUpdateStatus(req *types.AdminUserUpdateStatusRequest) (resp *types.AdminUserUpdateStatusResponse, err error) {
	_, err = l.svcCtx.UserServiceRPC.AdminUserUpdateStatus(l.ctx, &userrpc.AdminUserUpdateStatusRequest{
		Id:         req.Id,
		UserStatus: req.UserStatus,
	})
	if err != nil {
		logc.Error(l.ctx, "AdminUserUpdateStatus err: ", err)
		return nil, err
	}

	return
}
